package main.model.persistence;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import main.model.Diagram;

public class DiagramSaxParser {
	
	private SAXParserFactory factory = SAXParserFactory.newInstance();
	private SAXParser saxParser;
 	    
 	public Diagram parse(String diagramFilename){
 		DiagramHandler handler = new DiagramHandler(); 
 		if(factory != null ){
    		 try{
    			 saxParser = factory.newSAXParser();
    			 saxParser.parse(diagramFilename,  handler);
    		 }catch(Exception e){
    			 e.printStackTrace();
    		 }
    	 }
    	 return handler.getDiagram();
     }
	
}
